package com.androwit.engine.mapping.converter.str;

import com.androwit.engine.mapping.Converter;

public class StringDecoratorConverter implements Converter<Object, String> {

	protected String prefix, suffix;

	public StringDecoratorConverter(String prefix, String suffix) {
		this.prefix = prefix;
		this.suffix = suffix;
	}

	public String getPrefix() {
		return prefix;
	}

	public void setPrefix(String prefix) {
		this.prefix = prefix;
	}

	public String getSuffix() {
		return suffix;
	}

	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}

	@Override
	public Object fromConverted(String value) throws Exception {
		throw new UnsupportedOperationException("not implemented yet");
		// return value;
	}

	@Override
	public String convert(Object value) throws Exception {
		return cleanString(prefix) + cleanString(value) + cleanString(suffix);
	}

	protected String cleanString(Object value) {
		return value == null ? "" : value.toString();
	}

}
